﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace Xms.Abp.Core;

public interface IDistributedSemaphoreProvider
{
    string Name { get; }
    bool Release(string semaphoreName, int releaseCount = 1);
    Task<bool> ReleaseAsync(string semaphoreName, int releaseCount = 1, CancellationToken cancellationToken = default);
    bool CheckSemaphore(string semaphoreName, TimeSpan timeout, int initialCount = 1);
    Task<bool> CheckSemaphoreAsync(string semaphoreName, TimeSpan timeout, int initialCount = 1, CancellationToken cancellationToken = default);
    void Dispose(string semaphoreName);
}
